

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;

public class ControlPrincipal extends JFrame {
    JPanel principal;
     
    public void addComponentToPane(Container pane) throws IOException {
        ControlSelecionar cSelec = new ControlSelecionar();
        FormSelecionar selec = new FormSelecionar(cSelec);
         
        ControlProva cProva = new ControlProva();
        FormProva prova = new FormProva(cProva);
        
        ControlResolucao cResol = new ControlResolucao();
        FormResolucao resol = new FormResolucao(cResol);
        
        principal = new JPanel(new CardLayout());
        principal.add(selec, "Selecao");
        principal.add(prova, "Prova");
        principal.add(resol, "Resolucao");
        
        BufferedImage myPicture = ImageIO.read(new File("C://bio.jpg"));
        JLabel picLabel = new JLabel(new ImageIcon( myPicture.getScaledInstance(200, 100, 100) ));
        pane.add( picLabel, BorderLayout.PAGE_START );
        pane.add(principal, BorderLayout.CENTER);
        cSelec.setPrincipal(principal);
        cProva.setPrincipal(principal);
        cResol.setPrincipal(principal);
        cSelec.setForm(selec, prova);
        cProva.setForm(prova, resol);
    }
     
    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event dispatch thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("Passei!");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         
        //Create and set up the content pane.
        ControlPrincipal demo = new ControlPrincipal();
        try {
            demo.addComponentToPane(frame.getContentPane());
        } catch (IOException ex) {
            Logger.getLogger(ControlPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
         
        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }
     
    public static void main(String[] args) {
        /* Use an appropriate Look and Feel */
        try {
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        /* Turn off metal's use of bold fonts */
        UIManager.put("swing.boldMetal", Boolean.FALSE);
         
        //Schedule a job for the event dispatch thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}